home *** CD-ROM | disk | FTP | other *** search
- (Message inbox:1681)
- Received: from pop-2.iastate.edu by pop-1.iastate.edu with SMTP
- id AA02732; Thu, 4 Aug 1994 14:20:27 -0500
- Received: from theseas.ntua.gr by pop-2.iastate.edu with SMTP
- id AA20489; Thu, 4 Aug 1994 14:19:26 -0500
- Received: by theseas.ntua.gr with UUCP; Thu, 4 Aug 1994 22:19:19 +0300
- Received: by kriton.UUCP (V1.17-beta/Amiga)
- id <043e@kriton.UUCP>; Thu, 4 Aug 94 22:16:04 EET
- Date: Thu, 4 Aug 94 22:16:04 EET
- Message-Id: <9408042016.043e@kriton.UUCP>
- In-Reply-To: <9408040552.AA03514@alpha3.bogus.iastate.edu>
- (from <explorer@iastate.edu>)
- (at Thu, 4 Aug 1994 00:52:07 -0500)
- X-Mailer: //\\miga Electronic Mail (AmiElm 3.99)
- Organization: My Home
- Reply-To: kyrimis@theseas.ntua.gr
- Content-Length: 7759
- From: kriton!kyrimis@theseas.ntua.gr (Kriton Kyrimis)
- To: explorer@iastate.edu
- Subject: amigraphics.c
-
- I followed your suggestion of incorporating the color raypaint patches
- into my version. Adapting the Amiga display code proved much easier
- than I thought, and the result was certainly worth the trouble, even
- with a 32-color palette. I'm sending you the diffs to amigraphics.c to
- apply for the distribution.
- --
- Kriton (UUCP: pythia!theseas!kriton!kyrimis)
- (INTERNET: kyrimis@theseas.ntua.gr)
- -----
- "If they can use their brains, why can't we use ours?"
- -----
- *** raypaint/amigraphics.c.orig Thu Aug 4 19:09:25 1994
- --- raypaint/amigraphics.c Thu Aug 4 22:05:41 1994
- ***************
- *** 1,20 ****
- /*
- * The Amiga version of raypaint will open a 16 gray level black & white
- ! * screen of the appropriate size. It will use hires, lace, overscan, or
- ! * autoscroll to accommodate the entire picture. Both PAL and NTSC
- ! * machines should be catered for.
- *
- * If you have a three button mouse, the middle button should work as
- * described in the README file. If you do not, pressing both mouse
- * buttons will do the same thing (remember to deactivate any background
- * programs like DMouse that use pressing both mouse buttons to flip
- ! * between screens, etc).
- *
- * The code will only work on version 2.0 or higher of AmigaDOS.
- *
- * Send comments and bug reports to:
- *
- ! * Kriton Kyrimis UUCP: uunet!mcsun!ariadne!theseas!kriton!kyrimis
- * INTERNET: kyrimis@theseas.ntua.gr
- */
-
- --- 1,22 ----
- /*
- * The Amiga version of raypaint will open a 16 gray level black & white
- ! * screen or a 8/32 color screen (depending on whether hires is required for
- ! * the requested screen width or not) of the appropriate size. It will use
- ! * hires, lace, overscan, or autoscroll to accommodate the entire picture.
- ! * Both PAL and NTSC machines should be catered for.
- *
- * If you have a three button mouse, the middle button should work as
- * described in the README file. If you do not, pressing both mouse
- * buttons will do the same thing (remember to deactivate any background
- * programs like DMouse that use pressing both mouse buttons to flip
- ! * between screens, etc). Some of these programs can be fooled by pressing
- ! * the right mouse button first.
- *
- * The code will only work on version 2.0 or higher of AmigaDOS.
- *
- * Send comments and bug reports to:
- *
- ! * Kriton Kyrimis UUCP: pythia!theseas!kriton!kyrimis
- * INTERNET: kyrimis@theseas.ntua.gr
- */
-
- ***************
- *** 63,74 ****
- static void StripIntuiMessages(struct MsgPort *, struct Window *);
- static struct MsgPort *CreatePort(UBYTE *, LONG);
- static void DeletePort(struct MsgPort *);
-
- struct GfxBase *GfxBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
-
- static struct NewScreen screen = {
- ! 0, 0, 0, 0, 4, 0, 1, 0, AUTOSCROLL | CUSTOMSCREEN, NULL, "GetAmi", NULL, NULL
- };
-
- UWORD DriPens[] = { (UWORD)~0 };
- --- 65,78 ----
- static void StripIntuiMessages(struct MsgPort *, struct Window *);
- static struct MsgPort *CreatePort(UBYTE *, LONG);
- static void DeletePort(struct MsgPort *);
- + static void SetupGrayMap(void);
- + static void SetupColorMap(int);
-
- struct GfxBase *GfxBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
-
- static struct NewScreen screen = {
- ! 0, 0, 0, 0, 0, 0, 1, 0, AUTOSCROLL | CUSTOMSCREEN, NULL, NULL, NULL, NULL
- };
-
- UWORD DriPens[] = { (UWORD)~0 };
- ***************
- *** 109,119 ****
- static volatile int RMB=0;
- static volatile struct MsgPort *HandlerPort;
-
- void
- ! GraphicsInit(int xsize, int ysize, char *name)
- {
- BYTE pal;
- - int i;
-
- atexit(Cleanup);
- if ((GfxBase =
- --- 113,124 ----
- static volatile int RMB=0;
- static volatile struct MsgPort *HandlerPort;
-
- + static int gray, max_colors;
- +
- void
- ! GraphicsInit(int xsize, int ysize, char *name, int gray)
- {
- BYTE pal;
-
- atexit(Cleanup);
- if ((GfxBase =
- ***************
- *** 154,159 ****
- --- 159,173 ----
- }else{
- ScreenTags[DISPIDTAG].ti_Data |= NTSC_MONITOR_ID;
- }
- + if (gray) {
- + screen.Depth = 4;
- + }else{
- + if (screen.ViewModes & HIRES) {
- + screen.Depth = 3;
- + }else{
- + screen.Depth = 5;
- + }
- + }
- if ((s = OpenScreenTagList (&screen, ScreenTags)) == NULL){
- fprintf (stderr, "Can't open screen 1\n");
- Cleanup();
- ***************
- *** 168,181 ****
- }
- vp = &(s->ViewPort);
- rp = w->RPort;
- ! for (i=0; i<16; i++) {
- ! SetRGB4 (vp, i, i, i, i);
- }
-
- HandlerTask =
- CreateTask("Raypaint Mouse Handler", 1, (APTR)MouseHandler, 10000);
- }
-
- static int
- IsPAL(void)
- {
- --- 182,235 ----
- }
- vp = &(s->ViewPort);
- rp = w->RPort;
- !
- ! if (gray) {
- ! SetupGrayMap();
- ! }else{
- ! SetupColorMap(screen.Depth);
- }
-
- HandlerTask =
- CreateTask("Raypaint Mouse Handler", 1, (APTR)MouseHandler, 10000);
- }
-
- + static void
- + SetupGrayMap()
- + {
- + int i;
- +
- + gray = 1;
- + for (i=0; i<16; i++) {
- + SetRGB4 (vp, i, i, i, i);
- + }
- + }
- +
- + static void
- + SetupColorMap(int depth)
- + {
- + int col;
- + int r, g, b, red, green, blue;
- + double one_over_gamma = 0.4;
- +
- + gray = 0;
- + if (depth == 3) {
- + max_colors = 2;
- + }else{
- + max_colors = 3;
- + }
- + col = 0;
- + for (r = 0; r < max_colors; ++r) {
- + red = 15 * r / (max_colors-1);
- + for (g = 0; g < max_colors; ++g) {
- + green = 15 * g / (max_colors-1);
- + for (b = 0; b < max_colors; ++b) {
- + blue = 15 * b / (max_colors-1);
- + SetRGB4 (vp, col++, red, green, blue);
- + }
- + }
- + }
- + }
- +
- static int
- IsPAL(void)
- {
- ***************
- *** 227,242 ****
- void
- GraphicsDrawPixel(int xp, int yp, unsigned char color[3])
- {
- ! int idx;
-
- if (Done) {
- Cleanup();
- exit(RETURN_OK);
- }
- ! idx = (((0.35*(double)(color[0]) +
- ! 0.55*(double)(color[1]) +
- ! 0.10*(double)(color[2])) * 15.0) / 255.0) + 0.5;
- ! SetAPen(rp, idx);
- WritePixel(rp, MAPX(xp), MAPY(yp));
- }
-
- --- 281,305 ----
- void
- GraphicsDrawPixel(int xp, int yp, unsigned char color[3])
- {
- ! int val;
-
- if (Done) {
- Cleanup();
- exit(RETURN_OK);
- }
- !
- ! if (gray) {
- ! val = (((0.35*(double)(color[0]) +
- ! 0.55*(double)(color[1]) +
- ! 0.10*(double)(color[2])) * 15.0) / 255.0) + 0.5;
- ! }else{
- ! val = color[0] / 255.0 * (max_colors-1) + 0.5;
- ! val *= max_colors;
- ! val += color[1] / 255.0 * (max_colors-1) + 0.5;
- ! val *= max_colors;
- ! val += color[2] / 255.0 * (max_colors-1) + 0.5;
- ! }
- ! SetAPen(rp, val);
- WritePixel(rp, MAPX(xp), MAPY(yp));
- }
-
- ***************
- *** 250,265 ****
- unsigned char ll[3], unsigned char lr[3],
- unsigned char ur[3], unsigned char ul[3])
- {
- ! int idx;
-
- if (Done) {
- Cleanup();
- exit(RETURN_OK);
- }
- ! idx = (((0.35*(double)(ll[0]) +
- ! 0.55*(double)(ll[1]) +
- ! 0.10*(double)(ll[2])) * 15.0) / 255.0) + 0.5;
- ! SetAPen(rp, idx);
- RectFill(rp, MAPX(xp), MAPY(yp+ys), MAPX(xp+xs), MAPY(yp));
- }
-
- --- 313,336 ----
- unsigned char ll[3], unsigned char lr[3],
- unsigned char ur[3], unsigned char ul[3])
- {
- ! int val;
-
- if (Done) {
- Cleanup();
- exit(RETURN_OK);
- }
- ! if (gray) {
- ! val = (((0.35*(double)(ll[0]) +
- ! 0.55*(double)(ll[1]) +
- ! 0.10*(double)(ll[2])) * 15.0) / 255.0) + 0.5;
- ! }else{
- ! val = ll[0] / 255.0 * (max_colors-1) + 0.5;
- ! val *= max_colors;
- ! val += ll[1] / 255.0 * (max_colors-1) + 0.5;
- ! val *= max_colors;
- ! val += ll[2] / 255.0 * (max_colors-1) + 0.5;
- ! }
- ! SetAPen(rp, val);
- RectFill(rp, MAPX(xp), MAPY(yp+ys), MAPX(xp+xs), MAPY(yp));
- }
-
-